/*LIS Cross-section Data center in Luxembourg*/

/*email: usersupport@lisdatacenter.org*/

/*LIS Self Teaching Package 2022*/
/*Part I: Inequality, poverty, and social policy*/
/*SAS version*/

/*last change of this version of the syntax: 15-01-2022*/


/*Exercise 2: Sample selection and weighting*/

OPTIONS NOFMTERR NONOTES NOSOURCE NODATE NONUMBER NOCENTER LABEL LS=MAX PS=MAX;
TITLE "";

DATA current ;
 SET &gt06h (KEEP=dhi hifactor hpub_i hpub_u hpub_a hiprivate hxitsc hpopwgt nhhmem grossnet) ;
	miss_comp = 0 ;
	IF 	(dhi=. | hpub_i=. | hpub_u=. | hpub_a=. | hiprivate=. | hxitsc=.) THEN miss_comp = 1 ;
	ipwgt =  hpopwgt*nhhmem ; 
RUN ;

TITLE "Unweighted results, all cases" ;
PROC FREQ DATA=current ;
  TABLES miss_comp ;
RUN ;
PROC MEANS DATA=current N MEAN MEDIAN MIN MAX ;
  VAR dhi hifactor hpub_i hpub_u hpub_a hiprivate hxitsc hpopwgt ;
RUN ;
PROC FREQ DATA=current ;
  TABLES grossnet ;
RUN ;
TITLE "Weighted results, all cases" ;
PROC MEANS DATA=current N MEAN MEDIAN MIN MAX ;
  VAR dhi hifactor hpub_i hpub_u hpub_a hiprivate hxitsc hpopwgt ;
  WEIGHT ipwgt ;
RUN ;
TITLE "Weighted results, missing income cases dropped" ;
PROC MEANS DATA=current N MEAN MEDIAN MIN MAX ;
  VAR dhi hifactor hpub_i hpub_u hpub_a hiprivate hxitsc hpopwgt ;
  WEIGHT ipwgt ;
  WHERE miss_comp = 0 ;
RUN ;

PROC FREQ DATA=&gt06h;
  TABLES currency;
RUN;
